package com.github.prontera.controller;

import java.util.List;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.prontera.ApiVersion;
import com.github.prontera.RequestLogging;
import com.github.prontera.common.filter.CurrentUserId;
import com.github.prontera.domain.SysDict;
import com.github.prontera.domain.Tags;
import com.github.prontera.model.request.DictGroupTypeRequest;
import com.github.prontera.model.request.TagGroupTypeRequest;
import com.github.prontera.model.response.ObjectDataResponse;
import com.github.prontera.service.CommonDict;
import com.github.prontera.service.CommonTag;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;


/**
 * 标签
 */
@RestController
@Api(value = "标签")
@RequestMapping(value = ApiVersion.API_V1_PREFIX+"/tag")
public class TagController{

	/**
	 * 获取标签
	 */
	@RequestLogging
	@RequestMapping(value = "find", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "获取标签" , notes = "获取标签")
	public ObjectDataResponse<Tags> find(@ApiParam(hidden=true,name="登录用户ID")@CurrentUserId Long clientId,@RequestBody TagGroupTypeRequest TagGroupTypeRequest){
		Tags dicts=CommonTag.getTreeFileds(TagGroupTypeRequest.getTagGroupTypeEnum(),clientId);
		return new ObjectDataResponse<Tags>(dicts);
	}
	
	/**
	 * 获取系统标签
	 */
	
	@RequestMapping(value = "getDict", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "获取系统标签" , notes = "获取系统标签")
	public ObjectDataResponse<List<SysDict>> getDict(@ApiParam(hidden=true,name="登录用户ID")@CurrentUserId Long clientId,@RequestBody DictGroupTypeRequest dictGroupTypeRequest){
		List<SysDict> dicts=CommonDict.get(dictGroupTypeRequest.getGroupType().getDesc());
		return new ObjectDataResponse<List<SysDict>>(dicts);
	}
	
}
